/**
 * Copyright 2011 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.bitcoin.core;

import com.google.bitcoin.core.BlockChain.NewBlockType;

/**
 * Interface to listen for changes in a {@link BlockChain}.
 * 
 * @see BlockChain#addListener(BlockChainListener)
 */
public interface BlockChainListener {

    /**
     * This is called when a block has been connected somewhere in the chain.
     * (Chain head or side chain.)
     * 
     * @param block
     *            The block that has been connected
     */
    public void onNewBlock(BlockChain chain,StoredBlock block,NewBlockType blockType);

    /**
     * This is called after {@link #blockConnected(StoredBlock)} when the
     * connected block is the new chain head and does not follow the previous
     * chain head. The new blocked forks the chain at the split point.
     * 
     * @param newChainHead
     *            The new chain's head
     * @param oldChainHead
     *            The old chain's head
     * @param splitPoint
     *            The highest common block in the old and new chain
     */
    public void onReorganize(BlockChain chain,StoredBlock newChainHead,
            StoredBlock oldChainHead, StoredBlock splitPoint);
}
